home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-09-04 | 2.3 KB | 85 lines | [TEXT/CCL ] |
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;; Copyright 1987, 1988, 1989, 1990 by Ruben Kleiman for Apple Computer, Inc.
- ;;; Advanced Technology Group
- ;;;
-
- ;;;
- ;;; Tone Synthetizer sound functions
- ;;;
-
- (in-package :sound)
-
- (require :sound-info)
-
- (provide :tone-synth)
-
- (export '(do-pitch using-channel using-command with-command-setting
- do-command-on-channel))
-
- (defun do-pitch (&key (a #xFF) (f #x3C) (d 40))
- (%stack-block ((channel 4)
- (cmd 8))
- (%put-long channel 0 0) ; make sure that channel is a nil ptr
-
- (_SndNewChanne :ptr channel :word 1 :long 0 :ptr nil :word) ;; sound::noteSynth
-
- (%put-word cmd 40 0)
- (%put-word cmd d 2)
- (%put-byte cmd a 4)
- (%put-byte cmd #x00 5)
- (%put-byte cmd #x00 6)
- (%put-byte cmd f 7)
-
- (with-pointers ((p cmd))
- (_SndDoCommand :ptr (%get-ptr channel 0)
- :ptr p ; (%get-ptr SndCommand 0)
- :word 0
- :word))
-
- (_SndDisposeChannel :ptr (%get-ptr channel 0) :word 0)))45987351
-
-
- ;;; MACROS will be needed for smoother transitions between notes [see TEST]
-
- (defmacro using-channel ((channel channel-type) &body body)
- `(%stack-block ((,channel 4))
- (%put-long ,channel 0 0)
- (_SndNewChanne :ptr ,channel :word 1 :long 0 :ptr nil :word)
- ,@body
- (_SndDisposeChannel :ptr (%get-ptr ,channel 0) :word 0)))
-
- (defmacro using-command ((command) &body body)
- `(%stack-block ((,command 8))
- ,.body))
-
- (defmacro with-command-setting ((cmd-ptr type param1 param2) &body body)
- `(progn
- (%put-word ,cmd-ptr ,type 0)
- (%put-word ,cmd-ptr ,param1 2)
- (%put-full-long ,cmd-ptr ,param2 4)
- ,.body))
-
- (defmacro do-command-on-channel ((cmd channel))
- `(with-pointers ((p ,cmd))
- (_SndDoCommand :ptr (%get-ptr ,channel 0)
- :ptr p
- :word 0
- :word)))
-
-
- (defun test ()
- (using-channel (c 1)
- (using-command (cmd)
- (do ((i 50 (1+ i)))
- ((> i 127))
- (with-command-setting (cmd 40 1000
- (logior #xFF000000
- i))
- (print (list cmd c))
- (do-command-on-channel (cmd c)))))))
-
-
-
-
-
-